<?php
/**
 * CustomerEvents.php
 *
 * @copyright   2023 thingsworld.com.cn - All Rights Reserved
 * @link        http://thingsworld.com.cn/
 * @author      stiffer.chen <chenl@thingsworld.com.cn>
 * @created     2023-03-30 10:03:11
 * @modified    2023-03-30 10:03:11
 *
 */

namespace App\Http\Controllers;

use App\Repositories\EventRepo;
use App\Services\EventService;

class CustomerEventsController extends BaseController
{

    /**
     * @OA\Get(
     *     path="/customer_events/status",
     *     tags={"CustomerEvents"},
     *     summary="查看事件状态",
     *     description="查看事件状态",
     *     operationId="customer_event_status",
     *     security={{"bearerAuth":{}}},
     *     @OA\Response(response=200, description="请求成功"),
     *     @OA\Response(response=401,description="鉴权失败"),
     *     @OA\Response(response=422, description="请求异常")
     * )
     */
    public function status()
    {
        $status = EventRepo::status();
        return message('获取成功', 1, $status);
    }

    /**
     * @OA\Get(
     *     path="/customer_events/process",
     *     tags={"CustomerEvents"},
     *     summary="查看事件进度",
     *     description="查看事件进度",
     *     operationId="customer_event_process",
     *     security={{"bearerAuth":{}}},
     *     @OA\Parameter(name="type", in="query", description="事件类型", required=false, @OA\Schema(default="", type="string")),
     *     @OA\Parameter(name="status", in="query", description="状态", required=false, @OA\Schema(default="", type="string")),
     *     @OA\Parameter(name="page", in="query", description="当前页数", required=false, @OA\Schema(default="", type="integer")),
     *     @OA\Parameter(name="limit", in="query", description="每页数量(默认10)", required=false, @OA\Schema(default=10, type="integer")),
     *     @OA\Response(response=200, description="请求成功"),
     *     @OA\Response(response=401,description="鉴权失败"),
     *     @OA\Response(response=422, description="请求异常")
     * )
     */
    public function process()
    {
        $telephone = registry('account') ?? '';
        if (empty($telephone)) {
            return message('账号异常', true);
        }
        $service = new EventService($telephone);
        $data = $service->process();
        return list_message('获取成功', 1, $data);
    }
}